package com.chenglu.android.restaurant.adapter;

import android.content.Context;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.chenglu.android.R;
import com.chenglu.android.common.utils.GlideUtils;
import com.chenglu.android.common.utils.PxUtils;
import com.chenglu.android.common.utils.Utils;
import com.chenglu.android.restaurant.bean.RestaurantSearchBean;


import java.util.List;

/**
 * @author: lyj
 * @Created: by Copyright 2023/3/13 Guangzhou Hongma Technology Co., Ltd. All rights reserved.
 * @Description：首页评论图片的数据
 */
public class CenterItemPicAdapter extends BaseQuickAdapter<RestaurantSearchBean.Data.Records.GoodsVOList, BaseViewHolder> {

    private Context context ;
    public CenterItemPicAdapter(@Nullable Context context, List<RestaurantSearchBean.Data.Records.GoodsVOList> data) {
        super(R.layout.item_food_pic, data);
        this.context = context;

    }



    @Override
    protected void convert(@NonNull BaseViewHolder helper,RestaurantSearchBean.Data.Records.GoodsVOList item) {

        if(item!=null){
//            LogUtils.d("列表的数据"+ new Gson().toJson(item));
            ImageView imageView =  helper.getView(R.id.iv_pic);

            RequestOptions options = new RequestOptions()
                    .placeholder(R.color.color_f6f6f6)
                    .error(R.color.color_f6f6f6)
                    .override(160,160)
                    .transform(new RoundedCorners(PxUtils.dp2px(8)));
            Glide.with(context).load(item.getGoodsImg()).apply(options).into(imageView);
//            GlideUtils.setImageView(context,item.getGoodsImgList(),imageView,8);
            helper.setText(R.id.tv_item_title,item.getGoodsName());
            helper.setText(R.id.tv_item_price,"¥ "+ Utils.doubleTrans2(item.getGoodsPrice()));
        }

    }
}
